package com.mcflywzx.airhockey.programs;

import static android.opengl.GLES20.glUseProgram;
import android.content.Context;

import com.mcflywzx.airhockey.util.ShaderHelper;
import com.mcflywzx.airhockey.util.TextResourceReader;

public class ShaderProgram {
	//Uniform constants
	protected static final String U_COLOR = "u_Color";
	protected static final String U_MATRIX = "u_Matrix";
	protected static final String U_TEXTURE_UNIT = "u_TextureUnit";
	
	//Attribute constants
	protected static final String A_POSITION = "a_Position";
	protected static final String A_COLOR = "a_Color";
	protected static final String A_TEXTURE_COORDINATES = "a_TextureCoordinates";
	
	//shader program
	protected final int program;
	
	protected ShaderProgram(Context co, int vsResID, int fsResID) {
		//Compile the shaders and link the program.
		program = ShaderHelper.buildProgram(
				TextResourceReader.readTextFileFromResource(co, vsResID), 
				TextResourceReader.readTextFileFromResource(co, fsResID));
	}
	
	public void useProgram() {
		//Set the current OpenGL shader program to this program
		glUseProgram(program);
	}
}
